package com.wkbb.basic.service;

import com.github.pagehelper.PageInfo;
import com.wkbb.common.dto.basic.ClassInfo;
import com.wkbb.basic.model.User;
import com.wkbb.basic.model.UserOpen;
import com.wkbb.common.dto.ResultDTO;
import com.wkbb.common.dto.basic.*;
import com.wkbb.common.dto.im.ImUserDto;
import com.wkbb.common.dto.im.SchoolAddressBookDto;
import com.wkbb.common.dto.wx.AccountInfoDto;

import java.util.List;
import java.util.Map;

public interface UserOpenService {

    UserDto doUserByOpen(Boolean routeFlag, Integer loginType, Integer miniApp, UserDto userDto);

    List<ClassInfoDto> getClassListByUser(Long orgId, Long userId, Integer roleType);

    List<StudentInfoDto> getStudentInfoByStudent(Long orgId, Long userId);

    List<StudentInfoDto> getStudentInfoByFamily( Long userId);

    StudentInfoDto getStudentByFamily( Long studentUserId, Long familyUserId);

    ClassInfoDto getClassInfoDto(Long orgId, Long classId);

    ClassInfoDto getClassInfo(Map<String, Object> params);

    List<GradeTreeDto> getClassTree(Long id) throws Exception;

    void clearNickName(Long userId);

    SchoolAddressBookDto getFacultyAddressBook(Long orgId, Long userId,Integer type) throws  Exception;

    List<NickNameDto> getNickName(List<NickNameDto> nickNameDtos);

    String getAddressBookDelRedisKey(Long orgId, Long userId);

    String getAddressBookDelNotAllowRedisKey(Long orgId, Long userId);

    UserDto getUserInfoByMobile(Long accountId, String mobile);

    Boolean bindUser(Long accountId,Long visitorUserId,Long realUserId);

    User getUserExistAccount(Long accountId, String mobile);

    User getUserExistOrg(Long orgId, String mobile);

    UserUnionDto getUnionInfo(Long accountId, String unionId, Long userId);

    List<UserUnionDto> getUserUnionList(Map<String, Object> params);

    void deleteRedisAddressBookKey(Long userId,Integer type,Long orgId)throws  Exception;

    /**
     * 导入老师，只会影响教职工通讯录，不需要去清理家长通讯录。只有在后台把老师添加到班级任教里面才会影响家长通讯录
     * 导入学生和家长，会影响其他家长和班级任教的老师的通讯录
     * 因此要分情况清理通讯录缓存。
     * @param orgId
     * @param userType 要清理通讯录的用户类型，0家长（清理家长和教师通讯录） 2教师（只清理教师通讯录）。参照UserTypeEnum类的用户类型（0家长 1园长 2教师 3保育员 4 营养师 5代课教师 6其他）
     */
    void deleteRedisAddressBookByOrgId(Long orgId, Integer userType);

    /**
     * 多条件查询学生信息
     * @param params 学号或userId...
     * @return 学生信息
     */
    PageInfo<StudentInfoDto> getStudentPageList(Map<String, Object> params, Integer pageNo, Integer pageSize);

    /**
     * 多条件查询老师列表
     * @param params 查询条件
     * @param pageNo 当前页
     * @param pageSize 页大小
     * @return 分页对象
     */
    PageInfo<EmployeeInfoDto> getTeacherPageList(Map<String, Object> params, Integer pageNo, Integer pageSize) throws Exception;

    /**
     * 学校公众号用户绑定手机号接口
     */
    Boolean bindUserMobile(Long accountId, Long orgId, Long userId, String unionId, String openId, String mobile);

    /**获取用户绑定公众号*/
    public UserOpen getUserOpen(Long accountId, Long orgId, Long userId);

    //保存用户与公众号关联表
    void saveUserOpen(Integer loginType, Integer miniApp,Long accountId, Long userId, String unionId, String openId);

    /**
     * @param accountId
     * param openId
     */
    UserDto getUserDtoByAccountAndOpen(Long accountId,String openId);

    /**
     * @param orgId
     * @param keyname
     * @param scope
     * @param userid
     * param openId
     */
    String getAddressBookRedisKey(Long orgId, String keyname, String scope, Long userid);

    /**
     * @return
     */
    void saveImGroupByMasterId();

    /**
     * 单个家长或者老师-退,入班级群
     * @param operationType
     * @param orgId
     * @param classId
     * @param userId
     * @param studentId
     * @param roleType
     * @param userType
     * @return isDeleteImAccount
     */
    ResultDTO operateGroupUser(Integer operationType, Long orgId, Long classId, Long userId, Long studentId, Integer roleType, Integer userType, Boolean isDeleteImAccount);
    /**
     *
     * @param imUserDto
     * @return isDeleteImAccount
     */
    List<UserDto> getUserMobileList(List<ImUserDto> imUserDto);

    /**
     * 删除IM账号
     * @param orgId
     * @param userId
     * @param roleType
     * @param userType
     * @return
     */
    ResultDTO deleteImAccount(Long orgId,Long userId, Integer roleType, Integer userType);


    /**
     * 通过im账号获取当前用户的所有相关信息
     * @param imAccount
     * @return
     */
    List<ImUserDto> getUserInfoByImAccount(String imAccount);

    List<NickNameDto> setNickNameDto(Long userId, Long orgId, Integer roleType, Long studentId, Long classId);

    void repairImClassGroup(Long orgId);

    void repairChangeOwner(Long orgId);

    void repairBasicHeadUrl(String oldReplace,String newReplace);

    void repairUserSmart();

    Long getAccountIdByOrgId(Long orgId);

    void repairImAllInfo(Long orgId);

    void repairImClassGroupInfo(Long userId,Long orgId);

    String getUserOpenRedisKey(String accountId,String unionId);

    void repairImGroupInfoByClassId(List<ClassInfo> classInfoList, Boolean flag) throws Exception;

    List<AccountInfoDto> getAccountByUserMobile(String mobile);

    String getUserOpenId(Integer loginType, Integer miniApp, String unionId, String openId);

    List<UserDto> getVisitUser(List<UserDto> userList);

    Boolean getUserRoleById(Long orgId,Long userId);

    List<Integer> getUserRoleByOrgId(Long orgId,Long userId);

    void xmppUpdatePersonByRole(Long orgId,Long userId);

    Long getUserIdByCp(String corpId,String cpUserId);

    void saveUserUnion(Long accountId, Long userId, String unionId);

    void changeUserFace(Long camOrgId,Long camClassId,Long wxOrgId,Long wxClassId);

    void synCpWxUserFace(Long camOrgId,Long wxOrgId);

    UserUnionDto getUserByUnion(String unionId);

    List<StudentInfoDto> getStudentInfoByOrg(Long orgId,Long classId);

    UserDto wxLogin(UserDto userDto);

    ResultDTO<?> changeMobile(UserDto userDto) throws Exception;
}
